/*
 * @Description: 
 * @Author: HuRrongChao
 * @Date: 2025-01-09 16:27:04
 * @LastEditors: HuRrongChao
 * @LastEditTime: 2025-03-26 20:27:14
 */
import {
  ElButton,
  ElInput,
  ElLoading,
  ElSelect,
  ElOption,
  ElColorPicker,
  ElMessage,
  ElAvatar,
  ElIcon,
  ElRadio,
  ElPagination
} from 'element-plus'

import 'element-plus/dist/index.css'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

export default (app) => {
  app.use(ElButton, {
    locale: zhCn,
  })
  app.use(ElInput, {
    locale: zhCn,
  })
  app.use(ElLoading, {
    locale: zhCn,
  })
  app.use(ElSelect, {
    locale: zhCn,
  })
  app.use(ElOption, {
    locale: zhCn,
  })
  app.use(ElMessage, {
    locale: zhCn,
  })
  app.use(ElColorPicker, {
    locale: zhCn,
  })
  app.use(ElAvatar, {
    locale: zhCn,
  })
  app.use(ElIcon, {
    locale: zhCn,
  })
  app.use(ElRadio, {
    locale: zhCn,
  })
  app.use(ElPagination, {
    locale: zhCn,
  })
  app.config.globalProperties.$ELEMENT = { size: 'medium' }
  app.config.globalProperties.$loading = {
    loading: null,
    show: function (options = {}) { //使用：this.$loading.hide()
      if (!this.loading) {
        Object.assign(options, { lock: true })
        this.loading = ElLoading.service(options)
      }
    },
    hide: function () {
      if (this.loading) {
        this.loading.close()
        this.loading = null
      }
    }
  }
}
